package com.zzl.alligator.management.vote.service.impl;


import com.zzl.alligator.management.vote.mapper.VotePrincipalMapper;
import com.zzl.alligator.management.vote.domain.VotePrincipal;
import com.zzl.alligator.management.vote.service.IVotePrincipalService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * 投票主体(VotePrincipal)服务层
 *
 * @author zhouziliang
 * @since 2020-07-22
 */
@Service
public class VotePrincipalService implements IVotePrincipalService {
    
    @Autowired
    private VotePrincipalMapper votePrincipalMapper;
    
    /**
     * 通过ID查询单条数据
     *
     * @param principalId 主键
     * @return 实例对象
     */
    @Override
    public VotePrincipal findVotePrincipalById(Long principalId) {
        return votePrincipalMapper.findVotePrincipalById(principalId);
    }

   /**
     * 通过实体作为筛选条件查询
     *
     * @param votePrincipal 实例对象
     * @return 对象列表
     */
    @Override
    public List<VotePrincipal> findVotePrincipalList(VotePrincipal votePrincipal) {
        return votePrincipalMapper.findVotePrincipalList(votePrincipal);
    }

    /**
     * 新增数据
     *
     * @param votePrincipal 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertVotePrincipal(VotePrincipal votePrincipal) {
        return votePrincipalMapper.insertVotePrincipal(votePrincipal);
    }

    /**
     * 修改数据
     *
     * @param votePrincipal 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateVotePrincipal(VotePrincipal votePrincipal) {
        return votePrincipalMapper.updateVotePrincipal(votePrincipal);
    }

    /**
     * 通过主键删除数据
     *
     * @param principalId 主键
     * @return 是否成功
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteById(Long principalId) {
        return votePrincipalMapper.deleteById(principalId);
    } 
    
}